import ApiActivity from "@/api/activity";
import useRequest from "@/hooks/useRequest";

export default function useQrcode(callback: any) {
  // 生成收款码接口
  const {
    isFetching,
    run: runBuild,
    onFetchResponse: onResponseBuild,
  } = useRequest(ApiActivity.activityApplyBuild, { immediate: false });

  // 生成成功
  onResponseBuild(() => callback?.());

  /**
   *  生成事件
   * @param row 数据
   */
  async function buildQrcode(row: any) {
    runBuild({ id: row.id });
  }

  return {
    isFetching,
    buildQrcode,
  };
}
